<?php
$JO[ "Fashion" ] 		= JO(array(
		"EN"=>"JukeOn™ Fashion",
		"VI"=>"Thời Trang JukeOn™"
	) );
$JO["JO_searchid"] 	 	= JO(array("EN"=>"Search Key",			"VI"=>"Search"	));
$JO[ "Artist" ] 		= JO(array(
		"EN"=>"Artist",
		"VI"=>"Nghệ Sĩ"
	) );
/*if(!isset ($_SESSION["JO_account_key"]) || $_SESSION["JO_account_authority"]!="SO"){

	echo "<script>location='http://jukeon.vn/JO/';</script>";
}*/
$searchkeyartist=$JO["JO_searchid"];
$wherequery="";
if(isset ($_REQUEST["searchkey"])){
    $searchkeyartist=$_REQUEST["searchkey"];
    if($searchkeyartist!=$JO["JO_searchid"]){
        $wherequery= "and artist.`name` like '%".$searchkeyartist."%'";
    }
}
$page=1;
if(isset ($_REQUEST["Page"])){$page=$_REQUEST["Page"];}
?>
<script type="text/javascript">

$(document).ready(function() {
    $(".datepicker").datepicker({
        //changeYear:true

    });

    $(".datepicker").mask("99/99/9999", { placeholder: "_" });

});
window.onload = tuyen_du_lieu('VTL8x88','1',661);

function showobj(url,obj) {
    document.getElementById(obj).innerHTML="<div style=\"height: 45px;text-align: center;width:100%;background: url(JO_80_image/loading4.gif) center no-repeat\"><br/>Loadding...</div>";
    if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest(); }
    else {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
        xmlhttp.onreadystatechange=function() {
                if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                    document.getElementById(obj).innerHTML=xmlhttp.responseText;
                }
            }

    xmlhttp.open("GET",url,true);
    xmlhttp.send();
    
}
function tuyen_du_lieu(str)
{

if (str=="")
  {
	var str="VTL8x88";
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("load").innerHTML=xmlhttp.responseText;
    }
  }
	xmlhttp.open("GET","JO_64_ajax_TV_show.php?key="+str,true);
	xmlhttp.send();
}
</script>

<div class="JO_page">
  <h1>
    <?= $JO["Fashion"] ?>
  </h1>
  <h2>&nbsp;</h2>
  <h3>&nbsp;</h3>
</div>
<script type="text/javascript">
    var musics=new Array();
    var n=0;
</script>
<div class="JO_relative" style="width: 960px"> 
  <!--trai-->
  <div class="JO_left" style="width:240px">
    <div class="JO_box_240" style="margin-top:4px;position: relative;
margin: 4px;
padding: 28px 4px 4px 4px;
width: 222px;">
      <h1 style="margin-top:0px;position: absolute;
margin: 0px;
padding: 0px 0px 0px 8px;
left: -1px;
top: -1px;
width: 224px;
color: #464646 /* 80 */;
font-size: 11px;
font-family: tahoma;
line-height: 24px;

background-color: #EBEBEB;">Artist</h1>
       <table style="width: 100%">
      <?php
	  
	  $kenh=$_GET['kenh'];
	  $channel=$_GET['channel'];
	  $query = "
							SELECT		*
							FROM		`show_category`
							WHERE		`delete` IS NULL
													
						";
					
						
						$recordSet = JO_query( $query );
						
						if( $recordSet -> num_rows ) 
						while( $records = $recordSet -> fetch_array( ) ) {
						$records['image']=substr($records['image'],3);
						
			
	   ?>
        <tr style="margin-top:0 !important;font-weight:bold;" >
          <td  style="border-bottom:none"><a href="?JO_unit=64_TV_Show&channel=<?=$records['channel']?>&kenh=<?=$records['subject']?>"><img src="<?=$records['image']?>" width="100px" /></a></td>
          <td  style="border-bottom:none;width:60%;"><a href="?JO_unit=64_TV_Show&channel=<?=$records['channel']?>&kenh=<?=$records['subject']?>"><?=$records['subject']?></a><br />
           </td>
        </tr>
        <?php }
		else
		echo "ko có chương trình trên kênh này";
		?>
      </table>
          </div>
  </div>
  <!--end trai--> 
  <!--giua--> 
  <!-- artist-->
  <div class="JO_left"> 
    
    <!--end artist--> 
    <!--RBT-->
    <div class="JO_bar_480 youtube" style="width:452px;margin:4px;padding:8px">
    <?php
	$key=$_GET['key'];
	$quey="SELECT  *  FROM `show_detail` WHERE ".(isset($_GET['key'])?"`show`=$key":"`show`= 2 ")." AND `delete` IS NULL  limit 1";
	$recordSet=JO_query($quey);
	if($recordSet->num_rows) while( $record = $recordSet -> fetch_array( ) ) {
	$contentyoutube=html_entity_decode($record['url']);
	?>
    
      <?=
	  
	   $contentyoutube;
	  
	  ?>

    <?php }?>
      <?php
    	$channel=$_GET['channel'];
	  	$query = "
							SELECT		*
							FROM		`show_category`
							WHERE		`delete` IS NULL
							".(isset($_REQUEST["channel"])?" AND `channel`=$channel":" And `channel`= 2")."						
						";
						
						
						$recordSet = JO_query( $query );
						
						if( $recordSet -> num_rows ) 
						while( $records = $recordSet -> fetch_array( ) ) {
						
						
			
	   ?>
       
          <div class="JO_box_240" style="position: relative;
margin: 8px 4px 0 0;
padding: 28px 4px 4px 4px;
width:442px;font-weight:bold">
      <h1 style="margin-top:0px;position: absolute;
margin: 0px;
padding: 0px 0px 0px 8px;
left: -1px;
top: -1px;
width: 443px;
color: #464646 /* 80 */;
font-size: 11px;
font-family: tahoma;
line-height: 24px;

background-color: #EBEBEB;">Nhà Sản Xuất</h1>
     	<?= $records['note']?>
   	 	</div>
    <!--end RBT-->
   <?php }?>
    </div>
    <!--end RBT-->
     
  </div>
  <!--end giua--> 
  <!--phai-->
  <div class="JO_left">
    <div class="JO_box_240_0" style="margin-top:4px;position: relative;
margin: 4px;
padding: 26px 0px 4px 1px;
width: 222px;border:1px solid #EBEBEB">
      <h1 style="margin-top:0px;position: absolute;
margin: 0px;
padding: 0px 0px 0px 8px;
left: -1px;
top: -1px;
width: 224px;
color: #464646 /* 80 */;
font-size: 11px;
font-family: tahoma;
line-height: 24px;
background-color: #EBEBEB;">JukeOn TV</h1>
      <table style="width: 100%">
      <?php
	  $kenh='KMUSIC';
	  $kenh=$_GET['kenh'];
	  $channel=$_GET['channel'];
	  $query = "
							SELECT		*
							FROM		`show`
							WHERE		`delete` IS NULL
							".(isset($_REQUEST["channel"])?" AND `channel`=$channel":" And `channel`= 2")."
							limit 5
						
						";
					
					
						$recordSet = JO_query( $query );
						
						if( $recordSet -> num_rows ) 
						while( $records = $recordSet -> fetch_array( ) ) {
							
			
	   ?>
        <tr style="margin-top:0 !important" >
          <td  style="border-bottom:none;padding-top:0px"><a href="?JO_unit=64_TV_Show&channel=2&kenh=KMUSIC&key=<?=$records['key']?>"><img src="<?=$records['image']?>" width="100%" style="margin-top:4px"/></a></td>
          <td  style="border-bottom:none"><a href="?JO_unit=64_TV_Show&channel=2&kenh=KMUSIC&key=<?=$records['key']?>"><?=$records['subject']?></a><br />
           </td>
        </tr>
        <?php }
		else
		echo "ko có chương trình trên kênh này";
		?>
      </table>
    </div>
  </div>
  <!--end phai--> 
  <script type="text/javascript">
     function deleteimg(id){
         location = "JO_05_execution.php?JO_query=deleteimg&imgid="+id;
     }
     function changeupload(c){
         
         if(c.checked){
             var ct="<input type=\"file\" name=\"myfiles\" style=\"width: 300px;\"/>";
//             ct+="<input type=\"file\" name=\"myfiles[]\" style=\"width: 300px;\"/>";
//             ct+="<input type=\"file\" name=\"myfiles[]\" style=\"width: 300px;\"/>";
//             ct+="<input type=\"file\" name=\"myfiles[]\" style=\"width: 300px;\"/>";
//             ct+="<input type=\"file\" name=\"myfiles[]\" style=\"width: 300px;\"/>";
             document.getElementById("spimg").innerHTML=ct;
         }else{
             document.getElementById("spimg").innerHTML="<input type=\"text\" id=\"txtimgupload\" name=\"txtimgupload\" style=\"width: 300px;\"/>";
         }
     }
    function addtop(id){

        var contenttop="<span id='trtop_"+id+"'>";
        contenttop+="<table  style='width: 100%;margin: 0px 4px 0px 0px;'>";
        contenttop+="<tr >";
        contenttop+="<td style='width: 50px' id='tdtopid_"+id+"'>"+id+"</td>";
        contenttop+="<td id='tdtop_"+id+"'>"+document.getElementById("td_"+id).innerHTML+"</td>";
        contenttop+="<td style='width: 12px'><a href='#i' onclick='topup("+id+");'><img src='JO_80_image/JO_27_icon_up_on.png' class='JO_icon' alt='Up' title='Up'/></a></td>";
        contenttop+="<td style='width: 12px'><a href='#i' onclick='topdown("+id+");'><img src='JO_80_image/JO_28_icon_down_on.png' class='JO_icon' alt='Down' title='Down'/></a></td>";
        contenttop+="<td style='width: 12px'><a href='#i' onclick='removetop("+id+");'><img src='JO_80_image/JO_23_icon_delete_on.png' class='JO_icon' alt='Remove' title='Remove'/></a></td>";
        contenttop+="</tr>";
        contenttop+="</table>";
        contenttop+="</span>";
        document.getElementById("tb_top_music").innerHTML+=contenttop;

        //alert(document.getElementById("tb_top_music").innerHTML);
        var del = document.getElementById("tr_"+id);
        del.parentNode.removeChild(del);
        musics[n]=id;
        n++;
        //document.getElementById("kqkq").innerHTML=musics;
        create_top();
    }
    function removetop(id){

        var contentmusic="<span id='tr_"+id+"'>";
        contentmusic+="<table style='width: 100%;margin: 0px 4px 0px 0px;' >";
        contentmusic+="<tr ><td id='td_"+id+"'>"+document.getElementById("tdtop_"+id).innerHTML+"</td>";
        contentmusic+="<td style='width:12px'><a href='#i' onclick='addtop("+id+");'><img src='JO_80_image/add_top.png' class='JO_icon' alt='Add To Top Music' title='Add To Top Music'/></a></td>";
        contentmusic+="</tr>";
        contentmusic+="</table>";
        contentmusic+="</span>";
        document.getElementById("tb_music").innerHTML+=contentmusic;
        var del=document.getElementById("trtop_"+id);
        del.parentNode.removeChild(del);
        for(var i=0;i<musics.length;i++){
            if(musics[i]==id){
                musics[i]=undefined;
                create_top();
                break;
            }
        }

    }
    function topup(id){

        //alert(document.getElementById("trtop_"+id).id+":id");
        for(var i=0;i<musics.length;i++){
            if(musics[i]==id && i>0){
                var j=1;
                while(musics[i-j]==undefined && i-j>=0){

                    j++;
                }

                var contenttmp=document.getElementById("trtop_"+musics[i]).innerHTML;
//                var contenttmp2=document.getElementById("trtop_"+musics[i-j]);
//                var pct=contenttmp.parentNode;
//                pct.replaceChild(contenttmp,contenttmp2);
//                pct.replaceChild(contenttmp2,contenttmp);
                document.getElementById("trtop_"+musics[i]).innerHTML=document.getElementById("trtop_"+musics[i-j]).innerHTML;;
                document.getElementById("trtop_"+musics[i-j]).innerHTML=contenttmp;

                var idtmptr=document.getElementById("trtop_"+musics[i]).id;
                var idtmptr2=document.getElementById("trtop_"+musics[i-j]).id;
                document.getElementById("trtop_"+musics[i]).id=document.getElementById("trtop_"+musics[i]).id+"abc123";
                document.getElementById("trtop_"+musics[i-j]).id=idtmptr;
                document.getElementById("trtop_"+musics[i]+"abc123").id=idtmptr2

                //hoan vi 2 element
                var tmp=musics[i];
                musics[i]=musics[i-j];
                musics[i-j]=tmp;

                //document.getElementById("kqkq").innerHTML=musics;
                create_top();
                //alert(musics);
                break;
            }
        }

    }
    function topdown(id){
        //alert(document.getElementById("trtop_"+id).id+":id");
        for(var i=0;i<musics.length;i++){
            if(musics[i]==id){
                var j=1;
                while(musics[i+j]==undefined && i+j<musics.length){

                    j++;
                }
                if(musics[i+j]==undefined){ return;}
                //alert(musics[i]+":"+musics[i+j]);



                var contenttmpdown=document.getElementById("trtop_"+musics[i]).innerHTML;
                document.getElementById("trtop_"+musics[i]).innerHTML=document.getElementById("trtop_"+musics[i+j]).innerHTML;
                document.getElementById("trtop_"+musics[i+j]).innerHTML=contenttmpdown;
                //alert(document.getElementById("trtop_"+musics[i+j]).id);

                var idtmptr=document.getElementById("trtop_"+musics[i]).id;
                var idtmptr2=document.getElementById("trtop_"+musics[i+j]).id;
                document.getElementById("trtop_"+musics[i]).id=document.getElementById("trtop_"+musics[i]).id+"abc123";
                document.getElementById("trtop_"+musics[i+j]).id=idtmptr;
                document.getElementById("trtop_"+musics[i]+"abc123").id=idtmptr2;

                //hoan vi 2 element
                var tmp=musics[i];
                musics[i]=musics[i+j];
                musics[i+j]=tmp;

                //document.getElementById("kqkq").innerHTML=musics;
                create_top();
                //alert(musics);
                break;
            }
        }

    }
    function save(){

        var top=";";
        for(var i=0;i<musics.length;i++){
            if(musics[i]!=undefined){
                top+=musics[i]+";";
            }
        }
        //if(top==";"){return;}
		//alert(top);
        //
		//document.getElementById( "JO_integration_asynchronous" ).src = "JO_05_execution.php?JO_query=SaveTopArtist&top="+top+"&artist=<?=$artistid?>";
		location = "JO_05_execution.php?JO_query=SaveTopArtist&top="+top+"&artist=<?=$artistid?>";
    }
    function create_top()
    {
        var ntop=1;
        for(var i=0;i<musics.length;i++){
            if(musics[i]!=undefined){
                document.getElementById("tdtopid_"+musics[i]).innerHTML=ntop;
                ntop++;
            }
        }
    }
    function changeartist(c){
        location="JO_00_integration.php?JO_unit=31_Artist&artistid="+c.value+"&searchkey=<?=urlencode($searchkeyartist)?>";
    }
    function searchfocus(v){
        if(v.value=="<?=$JO["JO_searchid"]?>")
            v.value="";
    }
    function searchblur(v){
        var s=v.value;
        //Cắt bỏ những khoảng trắng đầu chuỗi
        while(s.charCodeAt(0)==32)
            s=s.substring(1);
        //Cắt bỏ những khoảng trắng cuối chuỗi
        while(s.charCodeAt(s.length-1)==32)
            s=s.substring(0,s.length-1);
        if(s=="")
            v.value="<?=$JO["JO_searchid"]?>";
        else
            v.value=s;
    }
    window.onload = function() {
        document.getElementById("txtsearchartist").focus();
    }
    function searchKeyPress(e)
    {
        // look for window.event in case event isn't passed in
        if (window.event) { e = window.event; }
        if (e.keyCode == 13)
        {
            key=document.getElementById("txtsearchartist").value;
            if(key=="<?=$JO["JO_searchid"]?>" || key==""){

                location=("JO_00_integration.php?JO_unit=31_Artist");
            }else{

                location=("JO_00_integration.php?JO_unit=31_Artist&searchkey="+document.getElementById("txtsearchartist").value);
            }

        }
    }
    function sendurl(p){
            <?
            if($searchkeyartist==$JO["JO_searchid"]){
              ?>
                location=("JO_00_integration.php?JO_unit=62_Top_Rbt&Page=1&key="+p);
                <?
            }else{
                ?>
                location=("JO_00_integration.php?JO_unit=62_Top_Rbt&Page=1&key="+p+"&searchkey=<?=urlencode($searchkeyartist)?>");
                <?
            }
            ?>

    }
    function sendurl2(p){
            <?
            if($searchkeyartist==$JO["JO_searchid"]){
              ?>
                location=("JO_00_integration.php?JO_unit=31_Artist&Page=<?=$page?>&artistid="+p);
                <?
            }else{
                ?>
                        location=("JO_00_integration.php?JO_unit=31_Artist&Page=<?=$page?>&artistid="+p+"&searchkey=<?=  urlencode($searchkeyartist)?>");
                <?
            }
            ?>

    }
 </script> 
</div>
